package com.fc.mall.controller;

import com.fc.mall.dto.CommonResult;
import com.fc.mall.dto.OmsOrderGroupBuyInfo;
import com.fc.mall.dto.OmsOrderGroupBuyQueryParam;
import com.fc.mall.service.OmsOrderGroupBuyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 拼团订单管理Controller
 */
@RestController
@Api(tags = "OmsGroupBuyOrderController", description = "拼团订单")
@RequestMapping("/groupbuy/{groupBuyId}")
public class OmsGroupBuyOrderController {
    @Autowired
    private OmsOrderGroupBuyService orderGroupBuyService;

    @ApiOperation("查询拼团订单")
    @RequestMapping(value = "/orders", method = RequestMethod.GET)
    public CommonResult list(@PathVariable Long groupBuyId,
                             OmsOrderGroupBuyQueryParam queryParam,
                             @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<OmsOrderGroupBuyInfo> orderList = orderGroupBuyService.queryOrderGroupBuys(groupBuyId, queryParam, pageSize, pageNum);
        return new CommonResult().pageSuccess(orderList);
    }
}
